package com.yanqu.road.server.gameplayer.module.manor.fishPondTaskCondition;

import com.yanqu.road.entity.manor.FishPondSpecialItemData;
import com.yanqu.road.entity.manor.FishPondTaskData;
import com.yanqu.road.entity.task.TaskConditionInfo;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.config.TaskMgr;

import java.math.BigInteger;

/**
 * @author ：zfr
 * @date ：2021/10/21 21:41
 */
public class FishingTypeSpecialItemCountCondition extends BaseFishPondCondition {

    public FishingTypeSpecialItemCountCondition(GamePlayer player, FishPondTaskData fishPondTaskData, Object initArgs, int eventType) {
        super(player, fishPondTaskData, initArgs, eventType);
    }

    @Override
    public void initValue() {
        Object initArgs = getInitArgs();
        if (initArgs != null) {
            changeValue(initArgs);
        }
    }

    @Override
    protected void changeValue(Object object) {
        TaskConditionInfo taskConditionInfo = TaskMgr.getTaskConditionById(getFishPondTaskData().getTaskId());
        FishPondSpecialItemData data = (FishPondSpecialItemData) object;
        if (data.getSpecialItemId() == taskConditionInfo.getParamList().get(2).intValue()) {
            setValue(BigInteger.valueOf(data.getCount()));
        }
    }
}
